package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.code.annotation.FormField;
import com.nbsaas.boot.code.annotation.bean.StoreStateBean;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import com.nbsaas.boot.order.ext.domain.simple.OrderExt;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@StoreStateBean
@Data
@FormAnnotation(title = "订单", model = "订单")
@Entity
@Table(name = "bs_order")
@org.hibernate.annotations.Table(appliesTo = "bs_order", comment = "订单")
public class Order extends LongEntity {

    @Comment("订单编号")
    private String orderNo;


    @Dict(items = {
            @DictItem(value = 1, label = "待支付"),
            @DictItem(value = 2, label = "待发货"),
            @DictItem(value = 3, label = "待收货"),
            @DictItem(value = 4, label = "待评价"),
            @DictItem(value = 5, label = "已完成"),
            @DictItem(value = 6, label = "已取消"),
    })
    @Comment("订单状态")
    private Integer state;

    @Dict(items = {
            @DictItem(value = 1, label = "微信"),
            @DictItem(value = 2, label = "支付宝"),
            @DictItem(value = 3, label = "银联"),
            @DictItem(value = 4, label = "快捷支付"),
            @DictItem(value = 5, label = "微信公众号"),
            @DictItem(value = 6, label = "微信小程序"),
    })
    @Comment("订单来源")
    private Integer sourceClient;


    @Dict(items = {
            @DictItem(value = 1, label = "普通订单"),
            @DictItem(value = 2, label = "团购订单"),
            @DictItem(value = 3, label = "秒杀订单")
    })
    @Comment("订单类型")
    private Integer catalog;

    @Type(type = "io.hypersistence.utils.hibernate.type.json.JsonType")
    @Column(columnDefinition = "json")
    private OrderExt orderExt;




    @Comment("订单数量")
    private Integer num;

    @Comment("下单人ID")
    private Long customerId;

    @Comment("商家ID")
    private Long merchantId;

    @Comment("门店ID")
    private Long storeId;


    @Comment("收货地址ID")
    private Long deliveryAddressId;

    @Comment("收货地址")
    private String deliveryAddress;

    @Comment("订单状态")
    private Integer orderStatus;

    @Comment("订单来源")
    private Integer orderSource;

    @Comment("订单类型")
    private Integer orderType;

    @Comment("下单时间")
    private Date orderTime;

    @Comment("支付时间")
    private Date paymentTime;

    @Comment("支付方式")
    private Integer paymentMethod;

    @Comment("支付状态")
    private Integer paymentStatus;



    @Comment("支付账户")
    private String paymentAccount;

    @Comment("支付备注")
    private String paymentNotes;


    @Comment("订单金额")
    private BigDecimal amount;

    @Comment("支付金额")
    private BigDecimal paymentAmount;

    @Comment("商家优惠金额")
    private BigDecimal merchantDiscount;

    @Comment("平台优惠金额")
    private BigDecimal platformDiscount;

    @Comment("积分抵扣金额")
    private BigDecimal pointsDeduction;

    @Comment("红包抵扣金额")
    private BigDecimal voucherDeduction;

    @Comment("总优惠金额")
    private BigDecimal totalDiscount;

    @Comment("实际付款金额")
    private BigDecimal actualPaymentAmount;

    @Comment("首款比例")
    private BigDecimal firstPaymentRatio;

    @Comment("首款")
    private BigDecimal firstPayment;

    @Comment("进度款")
    private BigDecimal progressPayment;

    @Comment("尾款")
    private BigDecimal finalPayment;

    @Comment("核验码")
    private String verificationCode;

    @Comment("核验时间")
    private Date verificationTime;

    @Comment("核销状态")
    private Integer verificationStatus;

    @Comment("发货单号")
    private String shippingNo;

    @Comment("发货时间")
    private Date shippingTime;



    @Comment("完成时间")
    private Date orderCompletionTime;

    @Comment("推荐人ID")
    private Long referrerId;

    @Comment("订单备注")
    private String orderNotes;

    @FormField(title = "添加时间", grid = true, width = "11111", ignore = true)
    @Comment("添加时间")
    private Date addDate;


    @Comment("最新修改时间")
    private Date lastDate;
}
